package com.hl.mapper;

import com.hl.pojo.Fm;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface FmMapper {

    // 添加FM信息
    @Insert("insert into fm (title, list_image, list_image_sketch) values (#{title}, #{listImage}, #{listImageSketch})")
    public Integer add(Fm fm);

//    // 删除FM信息（根据ID）
//    @Delete("delete from fm where id = #{id}")
//    public Integer deleteById(Integer id);

    // 逻辑删除FM信息（根据ID）
    @Update("update fm set del = 1 where id = #{id}")
    public Integer deleteLogicalById(Integer id);

    // 查询所有FM信息（未删除）
    @Select("select * from fm where del = 0")
    public List<Fm> findAll();

    // 根据ID查询FM信息
    @Select("select * from fm where id = #{id} and del = 0")
    public Fm findById(Integer id);

    // 更新FM信息
    @Update("update fm set title = #{title}, list_image = #{listImage}, list_image_sketch = #{listImageSketch} where id = #{id}")
    public Integer update(Fm fm);

    @Select("select * from fm where title = #{title} and del = 0")
    public List<Fm> findByTitle(String title);

}